package com.yogee.topseller.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yogee.core.base.BaseRecyclerAdapter;
import com.yogee.topseller.R;
import com.yogee.topseller.bean.SelectCommissionBean;

import java.util.List;
import java.util.concurrent.ConcurrentNavigableMap;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 佣金流水 adapter
 *
 * @auathor ${XiaoJianghong}
 * @date 2017/6/22.
 */

public class TXLCRvAdapter extends RecyclerView.Adapter<TXLCRvAdapter.ViewHolder> {
    private int type;
    private Context context;
    private List<SelectCommissionBean.CommListBean> data;

    public TXLCRvAdapter(Context context) {
        this.context = context;
    }

    public void addData(List<SelectCommissionBean.CommListBean> data, int type) {
        this.data = data;
        this.type = type;
        notifyDataSetChanged();
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(context).inflate(R.layout.item_txlc, parent, false);
        return new ViewHolder(v);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        SelectCommissionBean.CommListBean bean = data.get(position);

        holder.itemYjlsDateTv.setText(bean.getCreateDate());
        holder.itemYjlsMoneyTv.setText(bean.getMoney());
        holder.itemYjlsTxTv.setText(bean.getTitle());
        switch (type) {
            case 0:
                holder.itemYjlsStateTv.setText("待审核");
                break;
            case 1:
                holder.itemYjlsStateTv.setText("已审核");
                break;
            case 2:
                holder.itemYjlsStateTv.setText("待支付");
                break;
            case 3:
                holder.itemYjlsStateTv.setText("已支付");
                break;
        }
    }

    @Override
    public int getItemCount() {
        return data == null ? 0 : data.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.item_yjls_tx_tv)
        TextView itemYjlsTxTv;
        @BindView(R.id.item_yjls_date_tv)
        TextView itemYjlsDateTv;
        @BindView(R.id.item_yjls_money_tv)
        TextView itemYjlsMoneyTv;
        @BindView(R.id.item_yjls_tx_rl)
        RelativeLayout itemYjlsTxRl;
        @BindView(R.id.item_yjls_state_tv)
        TextView itemYjlsStateTv;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}